package ihm;

import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.EmptyBorder;
import java.awt.BorderLayout;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import java.awt.Color;
import java.awt.SystemColor;
import javax.swing.JSeparator;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Font;
import java.awt.Rectangle;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.table.DefaultTableModel;

public class MainFrame extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JTable table;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MainFrame frame = new MainFrame();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MainFrame() {
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 1024, 768);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setPreferredSize(new Dimension(this.getSize().width-5, this.getSize().height-40));
		contentPane.add(tabbedPane);
		
		JPanel panel = new JPanel();
		tabbedPane.addTab("Overview", null, panel, null);
		panel.setLayout(new BorderLayout(0, 0));
		
		JPanel sidePanel = new JPanel();
		sidePanel.setBackground(SystemColor.controlHighlight);
		sidePanel.setPreferredSize(new Dimension(200, 688));
		panel.add(sidePanel, BorderLayout.EAST);
		sidePanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
		
		JPanel balancePanel = new JPanel();
		balancePanel.setBackground(SystemColor.controlHighlight);
		balancePanel.setPreferredSize(new Dimension(sidePanel.getPreferredSize().width, 350));
		sidePanel.add(balancePanel);
		balancePanel.setLayout(new BorderLayout(0, 0));
		
		JPanel balanceInsidePanel = new JPanel();
		balanceInsidePanel.setBackground(SystemColor.controlHighlight);
		balancePanel.add(balanceInsidePanel, BorderLayout.CENTER);
		
		JLabel lblJulie = new JLabel("Laetitia: +100");
		lblJulie.setForeground(new Color(255, 0, 0));
		lblJulie.setFont(new Font("Verdana", Font.BOLD, 16));
		lblJulie.setPreferredSize(new Dimension(balancePanel.getPreferredSize().width-50, 30));
		balanceInsidePanel.add(lblJulie);
		
		JLabel label = new JLabel("Julie: -300");
		label.setPreferredSize(new Dimension(balancePanel.getPreferredSize().width-50, 30));
		label.setForeground(new Color(50, 205, 50));
		label.setFont(new Font("Verdana", Font.BOLD, 16));
		balanceInsidePanel.add(label);
		
		JLabel lblDanny = new JLabel("Danny: +100");
		lblDanny.setPreferredSize(new Dimension(balancePanel.getPreferredSize().width-50, 30));
		lblDanny.setForeground(new Color(255, 0, 0));
		lblDanny.setFont(new Font("Verdana", Font.BOLD, 16));
		balanceInsidePanel.add(lblDanny);
		
		JLabel label_2 = new JLabel("Julie: -300");
		label_2.setPreferredSize(new Dimension(balancePanel.getPreferredSize().width-50, 30));
		label_2.setForeground(new Color(50, 205, 50));
		label_2.setFont(new Font("Verdana", Font.BOLD, 16));
		balanceInsidePanel.add(label_2);
		
		JLabel label_4 = new JLabel("Julie: -300");
		label_4.setPreferredSize(new Dimension(balancePanel.getPreferredSize().width-50, 30));
		label_4.setForeground(new Color(50, 205, 50));
		label_4.setFont(new Font("Verdana", Font.BOLD, 16));
		balanceInsidePanel.add(label_4);
		
		JLabel label_3 = new JLabel("Julie: -300");
		label_3.setPreferredSize(new Dimension(balancePanel.getPreferredSize().width-50, 30));
		label_3.setForeground(new Color(50, 205, 50));
		label_3.setFont(new Font("Verdana", Font.BOLD, 16));
		balanceInsidePanel.add(label_3);
		
		JLabel label_5 = new JLabel("Julie: -300");
		label_5.setPreferredSize(new Dimension(balancePanel.getPreferredSize().width-50, 30));
		label_5.setForeground(new Color(50, 205, 50));
		label_5.setFont(new Font("Verdana", Font.BOLD, 16));
		balanceInsidePanel.add(label_5);
		
		JButton btnNewButton = new JButton("Cl\u00F4turer");
		balancePanel.add(btnNewButton, BorderLayout.SOUTH);
		
		JPanel menuPanel = new JPanel();
		menuPanel.setPreferredSize(new Dimension(sidePanel.getPreferredSize().width, 349));
		sidePanel.add(menuPanel);
		menuPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 100, 20));
		
		JButton btnNewButton_1 = new JButton("Ajouter paiement");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		menuPanel.add(btnNewButton_1);
		
		JButton btnNewButton_2 = new JButton("Ajouter un utilisateur");
		menuPanel.add(btnNewButton_2);
		
		JScrollPane scrollPane = new JScrollPane();
		panel.add(scrollPane, BorderLayout.CENTER);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
			},
			new String[] {
				"Date", "Payeur", "Montant", "Description", "Participants"
			}
		));
		int dateWidth = 50;
		int payeurWidth = 80;
		int montantWidth = 50;
		int descriptionWidth = 200;
		int participantsWidth = 350;
		table.getColumnModel().getColumn(0).setPreferredWidth(dateWidth);
		table.getColumnModel().getColumn(1).setPreferredWidth(payeurWidth);
		table.getColumnModel().getColumn(2).setPreferredWidth(montantWidth);
		table.getColumnModel().getColumn(3).setPreferredWidth(descriptionWidth);
		table.getColumnModel().getColumn(4).setPreferredWidth(participantsWidth);
		scrollPane.setViewportView(table);
	}
}
